{$contents}

{literal}
<div style="text-align:left; padding:10px;">


<h2></h2>

Before starting session you have to set session id for upload to work correctly in all operation systems.
<pre class="code">
&lt;?php
if (isset($_POST["PHPSESSID"])) 
	session_id($_POST["PHPSESSID"]);
session_start();
?&gt;
</pre>



<h2>Upload handler</h2>
Something like this should be somewhere in controller.<br />
<br />
if user login is required - be convinced that user is authorized.
<pre class="code">
&lt;?php
public function handleUpload() {
	$this->view->setTemplate(false); // disable temlate
	$im = new UploadImage();
	$im->icon->addUploaded( $_FILES['Filedata']['tmp_name'], $_FILES['Filedata']['name']);
	$im->save();
	echo '1'; // give atleast some output
	exit(0); // exit script successfully
}
?&gt;
</pre>



<h2>Source</h2>
<pre class="code">
&lt;?php

if( $_GET['deleteImage'] && $image = UploadImage::load($_GET['deleteImage']) ) {
	$image->delete();
}

function getIcon( &$row ) {
	return $row->icon->toHtml();
}
$panel = array(
	'title' => 'Multiple files upload',
	'layout' => 'table',
	'action' => $this->getUrl('upload/'.$id),
	'layoutConfig' => array(
		'columns' => 2,
		'columnWidths' => array( 150 ),
	),
	'items' => array(
		array(
			'type' => 'upload',
			'handlerUrl' => $this->getUrl('handleUpload/'),
			'refreshUrl' => $this->getUrl('upload/'),
			'fileTypes' => '*.png;*.jpg;*.gif;',
			'name' => 'image',
			'title' => 'Pildid',
		),
		array(
			'type' => 'imageGrid',
			'colspan' => 2,
			'ordering' => false,
			'source' => new DomArDataSource( UploadImage::query(), 99999),
			'fields' => array(
				array('handler'=>'getIcon'),
				array('type' => 'gridButton','value' => 'Delete','link' => $this->getUrl('upload/&deleteImage='),'confirmMessage' => 'Are you sure?',),
			),
		),
	),
);

		
$this->view->contents = DomFg::render( $panel );

?&gt;
</pre>
</div>
{/literal}